package 尚硅谷;

import java.lang.ref.WeakReference;

/**
 * @author zhangmin
 * @create 2022-03-25 22:44
 */
public class WeakReferenceDemo {

    public static void main(String[] args) {
        Object o1=new Object();
        WeakReference<Object> weakReference=new WeakReference<>(o1);
        System.out.println(o1);
        System.out.println(weakReference.get());
        o1=null;
        System.gc();
        System.out.println("=================================");
        System.out.println(o1);
        System.out.println(weakReference.get());
    }
}
